﻿using UnityEngine;
using System.Collections;



public enum GameState
{
  start,
  runing,
  over
}
public class manCCL : MonoBehaviour {

    public GameState state;
    public int numberCount = 0;
        // Use this for initialization

      

    int Touch;
    private Vector3 scale;
    private Vector3 peopleLeft;
    private Vector3 peopleRight;
    private Animator anim;
    public static bool isLeft=false;
    public numberCCL numccl;


    public GameObject message;
	void Awake () {
       // numccl=GameObject.FindGameObjectWithTag("Number").GetComponent<numberCCL>();
        Touch = Screen.width / 2;
        scale = new Vector3(-1,1,1);
        peopleLeft = new Vector3(-1.964f, -3.84f, 0);
        peopleRight = new Vector3(1.964f, -3.84f, 0);
        anim = GetComponent<Animator>();
        state = GameState.start;
	}
	
	// Update is called once per frame
	void Update () 
    {
        if (Input.GetMouseButtonDown(0) && state==GameState.runing)
        {
            numberCount++;
//            print(numberCount);
            audio.Play();
            if (Input.mousePosition.x < Touch)
            {
                transform.position = peopleLeft;
                transform.localScale = Vector3.one;
                isLeft = true;
            }
            else
            {
                transform.position = peopleRight;
                transform.localScale = scale;
                isLeft = false;
            }
            anim.SetTrigger("Attack");
            numccl.showCount(numberCount);
        }
        
	}
    void OnTriggerEnter2D(Collider2D other)
    {
       // print("888");
        state = GameState.over;
        message.SetActive(true);
        message.GetComponent<messageCCl>().ActiveSubCountBtn();

    }

}
